home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / Shape.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  3.2 KB  |  149 lines

  1. package symantec.itools.awt.shape;
  2.  
  3.  
  4. import java.awt.Canvas;
  5. import java.awt.Dimension;
  6. import java.awt.Color;
  7. import symantec.itools.awt.BevelStyle;
  8.  
  9.  
  10. /**
  11.  * Abstract class for shape components.
  12.  * This is the parent Shape class for the various
  13.  * shape components.
  14.  * @see symantec.itools.awt.shape.Ellipse
  15.  * @see symantec.itools.awt.shape.Rectangle
  16.  * @version 1.0, Nov 26, 1996
  17.  * @author Symantec
  18.  */
  19.  
  20. public abstract class Shape
  21.     extends    Canvas
  22.     implements BevelStyle
  23. {
  24.     /**
  25.      * Width of this shape.
  26.      */
  27.     protected int width;
  28.  
  29.     /**
  30.      * Height of this shape.
  31.      */
  32.     protected int height;
  33.  
  34.     /**
  35.      * Border style of this shape.
  36.      */
  37.     protected int style;
  38.  
  39.     /**
  40.      * Shape is filled if true.
  41.      */
  42.     protected boolean fill;
  43.  
  44.     /**
  45.      * Color to fill shape with if fill is true.
  46.      */
  47.  
  48.     protected Color fillColor;
  49.  
  50.     /**
  51.      * Construct default Shape with BEVEL_LINE style.
  52.      */
  53.     protected Shape()
  54.     {
  55.         style = BEVEL_LINE;
  56.     }
  57.  
  58.     /**
  59.      * Sets the border style of the shape.
  60.      * @see #getBevelStyle
  61.      */
  62.     public void setBevelStyle(int s)
  63.     {
  64.         style = s;
  65.         repaint();
  66.     }
  67.  
  68.     /**
  69.      * Returns the current style of the shape.
  70.      * @see #setBevelStyle
  71.      */
  72.     public int getBevelStyle()
  73.     {
  74.         return style;
  75.     }
  76.  
  77.     /**
  78.      * Sets the fill mode of the shape.
  79.      * @see #getFillMode
  80.      */
  81.     public void setFillMode(boolean f)
  82.     {
  83.         fill = f;
  84.         repaint();
  85.     }
  86.  
  87.     /**
  88.      * Returns the current fill mode of the shape.
  89.      * @see #setFillMode
  90.      */
  91.     public boolean getFillMode()
  92.     {
  93.         return fill;
  94.     }
  95.  
  96.     /**
  97.      * Sets the fill color of the shape.
  98.      * @see #getFillColor
  99.      */
  100.     public void setFillColor(Color color)
  101.     {
  102.         fillColor = color;
  103.         repaint();
  104.     }
  105.  
  106.     /**
  107.      * Returns the current fill color of the shape.
  108.      * @see #setFillColor
  109.      */
  110.     public Color getFillColor()
  111.     {
  112.         return fillColor;
  113.     }
  114.  
  115.     /**
  116.      * Moves and/or resizes this component.
  117.      * This is a standard Java AWT method which gets called to move and/or
  118.      * resize this component. Components that are in containers with layout
  119.      * managers should not call this method, but rely on the layout manager
  120.      * instead.
  121.      *
  122.      * @param x horizontal position in the parent's coordinate space
  123.      * @param y vertical position in the parent's coordinate space
  124.      * @param width the new width
  125.      * @param height the new height
  126.      */
  127.     public void reshape(int x, int y, int width, int height)
  128.     {
  129.         this.width  = width;
  130.         this.height = height;
  131.  
  132.         super.reshape(x, y, width, height);
  133.     }
  134.  
  135.     /**
  136.      * Returns the recommended dimensions to properly display this component.
  137.      * This is a standard Java AWT method which gets called to determine
  138.      * the recommended size of this component.
  139.      *
  140.      * @return horiziontal and vertical dimensions of 50, 50
  141.      *
  142.      * @see java.awt.Component#minimumSize
  143.      */
  144.     public Dimension preferredSize()
  145.     {
  146.         return new Dimension(50, 50);
  147.     }
  148. }
  149.